﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web;
    using WMS6.Web.InvTransferServiceRef;

    public class InvTransferServiceClientProxy : BasePage
    {
        public string AutoRevertAllocate(string transferID, string updatedBy)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.AutoRevertAllocate(transferID, updatedBy, pubParasInfo);
            }
        }

        public string DeteleOwnerTransferDetail(List<string> transferIDs, List<string> lineIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.DeteleOwnerTransferDetailInfo(transferIDs, lineIDs, pubParasInfo);
            }
        }

        public string DeteleOwnerTransferInfo(List<string> transferIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.DeteleOwnerTransferInfo(transferIDs, pubParasInfo);
            }
        }

        public string ExecuteInvOwnerTransfer(string transferID, string updatedBy)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.ExecuteInvOwnerTransfer(transferID, updatedBy, pubParasInfo);
            }
        }

        public static InvTransferServiceClientProxy GetInstance()
        {
            return new InvTransferServiceClientProxy();
        }

        public DataSet GetInvOwnerTransferInfoByQueryEntity(OwnerTransferQueryEntity transferQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.GetInvOwnerTransferInfoByQueryEntity(transferQuery, pubParasInfo);
            }
        }

        public OwnerTransferDetailInfo GetOwnerTransferDetailByID(string transferID, string LineID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.GetOwnerTransferDetailInfo(transferID, LineID, pubParasInfo);
            }
        }

        public OwnerTransferDetailInfo GetOwnerTransferDetailInfo(string transferID, string lineID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.GetOwnerTransferDetailInfo(transferID, lineID, pubParasInfo);
            }
        }

        public OwnerTransferInfo GetOwnerTransferInfoByID(string transferID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.GetOwnerTransferInfoByID(transferID, pubParasInfo);
            }
        }

        private PubParasInfo InitPubParasInfo()
        {
            if (base.UserInfo != null)
            {
                return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
            }
            HttpContext.Current.Response.Redirect("../Login.aspx?from=Logout", true);
            return null;
        }

        public string InsertOwnerTransferDetailInfo(OwnerTransferDetailInfo transferDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.InsertOwnerTransferDetailInfo(transferDetailInfo, pubParasInfo);
            }
        }

        public string InsertOwnerTransferInfo(OwnerTransferInfo transferInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.InsertOwnerTransferInfo(transferInfo, pubParasInfo);
            }
        }

        public string TransferAllocate(string transferID, string updatedBy)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.TransferAllocate(transferID, updatedBy, pubParasInfo);
            }
        }

        public string UpdateOwnerTransferDetail(OwnerTransferDetailInfo transferDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InvTransferServiceClient client = new InvTransferServiceClient("WSHttpBinding_IInvTransferService"))
            {
                return client.UpdateOwnerTransferDetailInfo(transferDetailInfo, pubParasInfo);
            }
        }
    }
}

